from dataclasses import dataclass, field
import string
from pathlib import Path
from typing import Dict, List

@dataclass
class DatabaseConfig:
    host: str = "localhost"
    port: int = 3306
    username: str = "root"
    password: str = ""
    database: str = "trading"

@dataclass
class TradingConfig:
    symbols: List[str] = field(default_factory=lambda: ["000001", "000002"])  # 默认股票列表
    # 其他交易相关配置...

@dataclass
class DataConfig:
    column_mappings: Dict[str, str] = field(default_factory=lambda: {
        "日期": "Date",            # 日期
        "股票代码": "Code",  # 股票代码
        "开盘": "Open",            # 开盘价
        "收盘": "Close",           # 收盘价
        "最高": "High",            # 最高价
        "最低": "Low",             # 最低价
        "成交量": "Volume",        # 成交量
        "成交额": "Amount",        # 成交额
        "振幅": "Amplitude",       # 振幅
        "涨跌幅": "Price Change %",# 涨跌幅
        "涨跌额": "Price Change",  # 涨跌额
        "换手率": "Turnover Rate"  # 换手率
    })
    market_data_path: Path = Path("data/market")

@dataclass
class Config:
    database: DatabaseConfig = field(default_factory=DatabaseConfig)
    trading: TradingConfig = field(default_factory=TradingConfig)
    data: DataConfig = field(default_factory=DataConfig)    
    def __post_init__(self):
        if self.trading.symbols is None:
            self.trading.symbols = ["AAPL", "GOOGL", "MSFT"] 
